package com.gdkm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gdkm.po.Doctor;
import com.gdkm.po.Drug;
import com.gdkm.po.Student;
import com.gdkm.service.DoctorService;
import com.gdkm.service.DrugService;

@Controller

public class DrugController {
	@Autowired
	DrugService service;
	
	
	@RequestMapping("/drug")
	public String ss() {
		return "drug";
		
	}
	
	
	@ResponseBody
	@RequestMapping("/list3")
	public List get(int y) {
		List<Drug> list2 = service.list2((y-1)*8, 8);
		System.out.println(list2.toString());
		return list2;
	}
	@RequestMapping("/drsave")
	public String save(String drug_number, String drug_name,String specifications,String price) {
		service.save1(drug_number, drug_name,specifications,price);
		return "drug";
		
	}
	
	@ResponseBody
	@RequestMapping("/drlist")
	public List get(String drug_number,String drug_name,int y) {
		 
		List<Drug> list = service.list3(drug_number, drug_name,(y-1)*8, 8);
		System.out.println("模糊"+list);
		return list;
	}
	@RequestMapping("/drdel")
	public String del(int id) {
		service.delete1(id);
		return "drug";
	}
	//更新
	@RequestMapping("/drupdate")
    public String update(Drug stu){
        service.update(stu);
        System.out.print(stu);
        return  "drug";
}

}
